package com.pth.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.HibernateTemplate;

import com.pth.dao.CommentDAO;
import com.pth.model.Comment;
import com.pth.model.Huati;

public class CommentDAOImpl implements CommentDAO {

	
	private HibernateTemplate template;
	
	public void save(Comment comment) {

		template.save(comment);
	}

	public void delete(Comment comment) {

		template.delete(comment);
		
	}

	public void update(Comment comment) {

		template.update(comment);
		
	}

	public Comment getCommentByid(int id) {

		return template.get(Comment.class, id);
	
	}

	public Comment getCommentByemail(String email) {

		String hql="from Comment c where c.email='"+email+"'";
	
		return null;
		
	}

	@SuppressWarnings("unchecked")
	public List<Comment> getCommentsByHuati(Huati huati) {
		
		String hql="from Comment c where c.huati.id="+huati.getId();
		
		return template.find(hql);
		
		
	}

	public HibernateTemplate getTemplate() {
		return template;
	}

	public void setTemplate(HibernateTemplate template) {
		this.template = template;
	}

}
